//
// Copyright (C) OpenSim Ltd.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//
#ifndef __INET_XMLUTILS_H
#define __INET_XMLUTILS_H

#include "inet/common/INETDefs.h"
#include "inet/networklayer/contract/ipv4/Ipv4Address.h"

namespace inet {

namespace xmlutils {

INET_API const cXMLElement *getUniqueChild(const cXMLElement *node, const char *name);
INET_API const cXMLElement *getUniqueChildIfExists(const cXMLElement *node, const char *name);

INET_API void checkTags(const cXMLElement *node, const char *allowed);

INET_API bool getParameterBoolValue(const cXMLElement *ptr, const char *name, bool def);
INET_API bool getParameterBoolValue(const cXMLElement *ptr, const char *name);
INET_API int getParameterIntValue(const cXMLElement *ptr, const char *name);
INET_API int getParameterIntValue(const cXMLElement *ptr, const char *name, int def);
INET_API const char *getParameterStrValue(const cXMLElement *ptr, const char *name);
INET_API const char *getParameterStrValue(const cXMLElement *ptr, const char *name, const char *def);
INET_API Ipv4Address getParameterIPAddressValue(const cXMLElement *ptr, const char *name);
INET_API Ipv4Address getParameterIPAddressValue(const cXMLElement *ptr, const char *name, Ipv4Address def);
INET_API double getParameterDoubleValue(const cXMLElement *ptr, const char *name);
INET_API double getParameterDoubleValue(const cXMLElement *ptr, const char *name, double def);

INET_API const char *getMandatoryAttribute(const cXMLElement& node, const char *attr);
INET_API const char *getMandatoryFilledAttribute(const cXMLElement& node, const char *attr);
INET_API bool getAttributeBoolValue(const cXMLElement *node, const char *attrName, bool defVal);
INET_API bool getAttributeBoolValue(const cXMLElement *node, const char *attrName);

INET_API bool parseBool(const char *text);

} // namespace xmlutils

} // namespace inet

#endif // ifndef __INET_XMLUTILS_H

